package edu.sctu.zcy.month201505.day20150520;

/**
* Created by user24 on 2015/5/20.
*/
public class TextMore {

    TeaCher[] teaChers;

    public TextMore(TeaCher[] teaChers) {
        this.teaChers = teaChers;

    }

    public TeaCher[] sortTeacher() {

        TeaCher[] teaChers1;
        int change;
        int one;
        int two;
        for (int i = 0; i < teaChers.length; i++) {
            for (int j = 0; j < teaChers.length - 1; j++) {

                one = teaChers[j].getNumber();
                two = teaChers[j + 1].getNumber();
                if (one < two) {

                    change = one;
                    one = two;
                    two = change;
                }
            }
        }
        teaChers1 = teaChers;
        return teaChers1;
    }


    public Student[] sortStudent() {

        Student[] students = new Student[teaChers.length*3];
        Student[] student ;
        int change;
        int one;
        int two;
        for (int i = 0; i < teaChers.length; i++) {
            for (int j = 0; j < teaChers[i].getStudents().length; j++) {
                students = teaChers[i].getStudents();
            }
        }

        for (int i = 0; i < students.length; i++) {
            for (int j = 0; j < students.length - 1; j++) {
                one = students[j].getScore();
                two = students[j + 1].getScore();
                if (students[j].getScore() > students[j].getScore()) {

                    change = one;
                    one = two;
                    two = change;

                }
            }
        }
        student = students;
        return student;
    }

    public TeaCher[] pritCoded(){

        TeaCher[] teaChers1 = new TeaCher[teaChers.length];
        //teacher1里可能会有空值，所以后面引用的时候必须判断是否为空，否则会报错

        int k = 0;
        for (int i = 0; i < teaChers.length; i++) {

            if(teaChers[i].getTechnicalTitle().equals("教授")){

                teaChers1[k] = teaChers[i];

                k++;
            }
        }
        return teaChers1;

    }

}
